package com.liba.logic.service.impl;

import com.liba.logic.entity.UserBean;
import com.liba.logic.mapper.UserMapper;
import com.liba.logic.service.UserService;
import com.liba.logic.utils.JwtUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    UserMapper userMapper;

    @Override
    public UserBean queryUserById(String username) {

       return  userMapper.queryUserById(username);
    }

    @Override
    public String generateJwtToken(String username) {

        Map<String,Object> claims =new HashMap<>();
        claims.put("username",username);
        int expirationSeconds=10;
        String subject ="appLogin";

        return  JwtUtils.generateToken(subject, expirationSeconds,claims);


    }
}
